#include "widget.h"


Widget::Widget(QWidget *parent)
    : QWidget(parent)
{

    this->setFixedSize(1800,1015);//设置窗口大小
    this->setWindowTitle("捕鱼达人");//设置标题
    this->setWindowIcon(QIcon("img/icon"));//设置应用图标

    //设置窗口背景
    QPalette palette;//创建一个调色板
    palette.setBrush(QPalette::Window,QBrush(QPixmap("img/background")));//添加背景图片
    this->setPalette(palette);//调色板实例化

    //设置标签
    label=new QLabel(this);
    label->setPixmap(QPixmap("img/logo"));
    label->move(this->width()/2-300,this->height()/8);


    //设置按钮

    //开始按钮
    play=new QPushButton(this);
    play->setIcon(QIcon("img/play"));
    play->setIconSize(QSize(500,200));
    play->setFlat(true);
    play->move(this->width()/2-277,this->height()/3+150);
//    this->setFocusPolicy(Qt::NoFocus);



    //退出按钮
    quit=new QPushButton(this);
    quit->setIcon(QIcon("img/quit"));
    quit->setIconSize(QSize(500,200));
    quit->setFlat(true);
    quit->move(this->width()/2-277,this->height()-350);
//    this->setFocusPolicy(Qt::NoFocus);


    //连接信号
    this->connect(play,SIGNAL(clicked()),this,SLOT(clickplay()));
    this->connect(quit,SIGNAL(clicked()),this,SLOT(clickquit()));

    //创建副窗体
    game_w=new gamewidget(this);
    game_w->hide();
}


//槽函数具体定义


void Widget::clickplay()//play键的槽函数
{

    game_w->show();

}


void Widget::clickquit()//quit键的槽函数
{
    this->close();
    this->~Widget();
}


//析构函数
Widget::~Widget()
{
}


